<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Freetype OpenGL: texture-atlas.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="style.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="content"><!-- do not remove this div! -->

<div id="top"><!-- do not remove this div! -->

  
  <div id="titlearea">
    
    <div id="projectname">Freetype OpenGL</div>
    
    
    <div id="projectbrief">A high quality OpenGL text rendering engine for C</div>
    
  </div>
  

<!--

<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Freetype OpenGL
   &#160;<span id="projectnumber">0.1</span>
   </div>
   <div id="projectbrief">A high quality OpenGL text rendering engine for C</div>
  </td>
  
  
  
   
  
 </tr>
 </tbody>
</table>
</div>
-->


<!-- Generated by Doxygen 1.8.0 -->
<script type="text/javascript" src="dynsections.js"></script>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">texture-atlas.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="texture-atlas_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* ============================================================================</span>
<a name="l00002"></a>00002 <span class="comment"> * Freetype GL - A C OpenGL Freetype engine</span>
<a name="l00003"></a>00003 <span class="comment"> * Platform:    Any</span>
<a name="l00004"></a>00004 <span class="comment"> * WWW:         http://code.google.com/p/freetype-gl/</span>
<a name="l00005"></a>00005 <span class="comment"> * ----------------------------------------------------------------------------</span>
<a name="l00006"></a>00006 <span class="comment"> * Copyright 2011,2012 Nicolas P. Rougier. All rights reserved.</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
<a name="l00009"></a>00009 <span class="comment"> * modification, are permitted provided that the following conditions are met:</span>
<a name="l00010"></a>00010 <span class="comment"> *</span>
<a name="l00011"></a>00011 <span class="comment"> *  1. Redistributions of source code must retain the above copyright notice,</span>
<a name="l00012"></a>00012 <span class="comment"> *     this list of conditions and the following disclaimer.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> *  2. Redistributions in binary form must reproduce the above copyright</span>
<a name="l00015"></a>00015 <span class="comment"> *     notice, this list of conditions and the following disclaimer in the</span>
<a name="l00016"></a>00016 <span class="comment"> *     documentation and/or other materials provided with the distribution.</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER &#39;&#39;AS IS&#39;&#39; AND ANY EXPRESS OR</span>
<a name="l00019"></a>00019 <span class="comment"> * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF</span>
<a name="l00020"></a>00020 <span class="comment"> * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO</span>
<a name="l00021"></a>00021 <span class="comment"> * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,</span>
<a name="l00022"></a>00022 <span class="comment"> * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES</span>
<a name="l00023"></a>00023 <span class="comment"> * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;</span>
<a name="l00024"></a>00024 <span class="comment"> * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND</span>
<a name="l00025"></a>00025 <span class="comment"> * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span>
<a name="l00026"></a>00026 <span class="comment"> * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF</span>
<a name="l00027"></a>00027 <span class="comment"> * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00028"></a>00028 <span class="comment"> *</span>
<a name="l00029"></a>00029 <span class="comment"> * The views and conclusions contained in the software and documentation are</span>
<a name="l00030"></a>00030 <span class="comment"> * those of the authors and should not be interpreted as representing official</span>
<a name="l00031"></a>00031 <span class="comment"> * policies, either expressed or implied, of Nicolas P. Rougier.</span>
<a name="l00032"></a>00032 <span class="comment"> * ============================================================================</span>
<a name="l00033"></a>00033 <span class="comment"> *</span>
<a name="l00034"></a>00034 <span class="comment"> * This source is based on the article by Jukka Jylänki :</span>
<a name="l00035"></a>00035 <span class="comment"> * &quot;A Thousand Ways to Pack the Bin - A Practical Approach to</span>
<a name="l00036"></a>00036 <span class="comment"> * Two-Dimensional Rectangle Bin Packing&quot;, February 27, 2010.</span>
<a name="l00037"></a>00037 <span class="comment"> *</span>
<a name="l00038"></a>00038 <span class="comment"> * More precisely, this is an implementation of the Skyline Bottom-Left</span>
<a name="l00039"></a>00039 <span class="comment"> * algorithm based on C++ sources provided by Jukka Jylänki at:</span>
<a name="l00040"></a>00040 <span class="comment"> * http://clb.demon.fi/files/RectangleBinPack/</span>
<a name="l00041"></a>00041 <span class="comment"> *</span>
<a name="l00042"></a>00042 <span class="comment"> *  ============================================================================</span>
<a name="l00043"></a>00043 <span class="comment"> */</span>
<a name="l00044"></a>00044 <span class="preprocessor">#ifndef __TEXTURE_ATLAS_H__</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span><span class="preprocessor">#define __TEXTURE_ATLAS_H__</span>
<a name="l00046"></a>00046 <span class="preprocessor"></span>
<a name="l00047"></a>00047 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {
<a name="l00049"></a>00049 <span class="preprocessor">#endif</span>
<a name="l00050"></a>00050 <span class="preprocessor"></span>
<a name="l00051"></a>00051 <span class="preprocessor">#include &quot;<a class="code" href="vector_8h.html">vector.h</a>&quot;</span>
<a name="l00052"></a>00052 <span class="preprocessor">#include &quot;vec234.h&quot;</span>
<a name="l00053"></a>00053 
<a name="l00077"></a>00077  * <a class="code" href="structtexture__atlas__t.html" title="A texture atlas is used to pack several small regions into a single texture.">texture_atlas_t</a> * atlas = <a class="code" href="group__texture-atlas.html#ga7769be70f630e0a8a8b320525a07382d" title="Creates a new empty texture atlas.">texture_atlas_new</a>( 512, 512, 1 );
<a name="l00078"></a>00078  *
<a name="l00079"></a>00079  * <span class="comment">/* Allocates a region of 20x20 */</span>
<a name="l00080"></a>00080  * <a class="code" href="unionivec4.html" title="Tuple of 4 ints.">ivec4</a> region = <a class="code" href="group__texture-atlas.html#ga97c3b768599f7caebac33292619421ca" title="Allocate a new region in the atlas.">texture_atlas_get_region</a>( atlas, 20, 20 );
<a name="l00081"></a>00081  *
<a name="l00082"></a>00082  * <span class="comment">/* Fill region with some data */</span>
<a name="l00083"></a>00083  * <a class="code" href="group__texture-atlas.html#gafd130ce3015e5120ab62669ccdc7552d" title="Upload data to the specified atlas region.">texture_atlas_set_region</a>( atlas, region.<a class="code" href="unionivec4.html#a23145e2d274c7f165dec8e83bb80f690" title="Alias for first component.">x</a>, region.<a class="code" href="unionivec4.html#af31284e1d1a00ab2baf19c1290e90352" title="Alias for second component.">y</a>, region.<a class="code" href="unionivec4.html#a9d0e4978d049ba65b2165217953552f2" title="Alias for third component.">width</a>, region.<a class="code" href="unionivec4.html#afee981dd94e13fdfb8a5f737da9efc0a" title="Alias for fourth component.">height</a>, data, stride )
<a name="l00084"></a>00084  *
<a name="l00085"></a>00085  * ...
<a name="l00086"></a>00086  *
<a name="l00087"></a>00087  * <span class="keyword">@end</span>code
<a name="l00088"></a>00088  *
<a name="l00089"></a>00089  * @{
<a name="l00090"></a>00090  */
<a name="l00091"></a>00091 
<a name="l00092"></a>00092 
<a name="l00096"></a><a class="code" href="structtexture__atlas__t.html">00096</a> <span class="keyword">typedef</span> <span class="keyword">struct</span>
<a name="l00097"></a>00097 {
<a name="l00101"></a><a class="code" href="structtexture__atlas__t.html#a975fcc5072f14e9daade21c4ebf73601">00101</a>     <a class="code" href="structvector__t.html" title="Generic vector structure.">vector_t</a> * <a class="code" href="structtexture__atlas__t.html#a975fcc5072f14e9daade21c4ebf73601" title="Allocated nodes.">nodes</a>;
<a name="l00102"></a>00102 
<a name="l00106"></a><a class="code" href="structtexture__atlas__t.html#aa1fb802d48b70dc43e06e88f55f986aa">00106</a>     <span class="keywordtype">size_t</span> <a class="code" href="structtexture__atlas__t.html#aa1fb802d48b70dc43e06e88f55f986aa" title="Width (in pixels) of the underlying texture.">width</a>;
<a name="l00107"></a>00107 
<a name="l00111"></a><a class="code" href="structtexture__atlas__t.html#a724b0e35c619f88b231eba83c39095cb">00111</a>     <span class="keywordtype">size_t</span> <a class="code" href="structtexture__atlas__t.html#a724b0e35c619f88b231eba83c39095cb" title="Height (in pixels) of the underlying texture.">height</a>;
<a name="l00112"></a>00112 
<a name="l00116"></a><a class="code" href="structtexture__atlas__t.html#a099b3a476240070bc06248218c9e230c">00116</a>     <span class="keywordtype">size_t</span> <a class="code" href="structtexture__atlas__t.html#a099b3a476240070bc06248218c9e230c" title="Depth (in bytes) of the underlying texture.">depth</a>;
<a name="l00117"></a>00117 
<a name="l00121"></a><a class="code" href="structtexture__atlas__t.html#af56de920973c1cb4621e31af7aeaf276">00121</a>     <span class="keywordtype">size_t</span> <a class="code" href="structtexture__atlas__t.html#af56de920973c1cb4621e31af7aeaf276" title="Allocated surface size.">used</a>;
<a name="l00122"></a>00122 
<a name="l00126"></a><a class="code" href="structtexture__atlas__t.html#a03e72bd01b6e5e97c0cc032d22c11c45">00126</a>     <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="structtexture__atlas__t.html#a03e72bd01b6e5e97c0cc032d22c11c45" title="Texture identity (OpenGL)">id</a>;
<a name="l00127"></a>00127 
<a name="l00131"></a><a class="code" href="structtexture__atlas__t.html#a80f633ead9dbf1fb0c49503324f30753">00131</a>     <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> * <a class="code" href="structtexture__atlas__t.html#a80f633ead9dbf1fb0c49503324f30753" title="Atlas data.">data</a>;
<a name="l00132"></a>00132 
<a name="l00133"></a>00133 } <a class="code" href="structtexture__atlas__t.html" title="A texture atlas is used to pack several small regions into a single texture.">texture_atlas_t</a>;
<a name="l00134"></a>00134 
<a name="l00135"></a>00135 
<a name="l00136"></a>00136 
<a name="l00146"></a>00146   <a class="code" href="structtexture__atlas__t.html" title="A texture atlas is used to pack several small regions into a single texture.">texture_atlas_t</a> *
<a name="l00147"></a>00147   <a class="code" href="group__texture-atlas.html#ga7769be70f630e0a8a8b320525a07382d" title="Creates a new empty texture atlas.">texture_atlas_new</a>( <span class="keyword">const</span> <span class="keywordtype">size_t</span> width,
<a name="l00148"></a>00148                      <span class="keyword">const</span> <span class="keywordtype">size_t</span> height,
<a name="l00149"></a>00149                      <span class="keyword">const</span> <span class="keywordtype">size_t</span> depth );
<a name="l00150"></a>00150 
<a name="l00151"></a>00151 
<a name="l00158"></a>00158   <span class="keywordtype">void</span>
<a name="l00159"></a>00159   <a class="code" href="group__texture-atlas.html#gac3fc1f3aaa1a18945bd1883aa18fb7ef" title="Deletes a texture atlas.">texture_atlas_delete</a>( <a class="code" href="structtexture__atlas__t.html" title="A texture atlas is used to pack several small regions into a single texture.">texture_atlas_t</a> * <span class="keyword">self</span> );
<a name="l00160"></a>00160 
<a name="l00161"></a>00161 
<a name="l00168"></a>00168   <span class="keywordtype">void</span>
<a name="l00169"></a>00169   <a class="code" href="group__texture-atlas.html#ga9200360ad560fca395e20ca80463dfd8" title="Upload atlas to video memory.">texture_atlas_upload</a>( <a class="code" href="structtexture__atlas__t.html" title="A texture atlas is used to pack several small regions into a single texture.">texture_atlas_t</a> * <span class="keyword">self</span> );
<a name="l00170"></a>00170 
<a name="l00171"></a>00171 
<a name="l00181"></a>00181   <a class="code" href="unionivec4.html" title="Tuple of 4 ints.">ivec4</a>
<a name="l00182"></a>00182   <a class="code" href="group__texture-atlas.html#ga97c3b768599f7caebac33292619421ca" title="Allocate a new region in the atlas.">texture_atlas_get_region</a>( <a class="code" href="structtexture__atlas__t.html" title="A texture atlas is used to pack several small regions into a single texture.">texture_atlas_t</a> * <span class="keyword">self</span>,
<a name="l00183"></a>00183                             <span class="keyword">const</span> <span class="keywordtype">size_t</span> width,
<a name="l00184"></a>00184                             <span class="keyword">const</span> <span class="keywordtype">size_t</span> height );
<a name="l00185"></a>00185 
<a name="l00186"></a>00186 
<a name="l00199"></a>00199   <span class="keywordtype">void</span>
<a name="l00200"></a>00200   <a class="code" href="group__texture-atlas.html#gafd130ce3015e5120ab62669ccdc7552d" title="Upload data to the specified atlas region.">texture_atlas_set_region</a>( <a class="code" href="structtexture__atlas__t.html" title="A texture atlas is used to pack several small regions into a single texture.">texture_atlas_t</a> * <span class="keyword">self</span>,
<a name="l00201"></a>00201                             <span class="keyword">const</span> <span class="keywordtype">size_t</span> x,
<a name="l00202"></a>00202                             <span class="keyword">const</span> <span class="keywordtype">size_t</span> y,
<a name="l00203"></a>00203                             <span class="keyword">const</span> <span class="keywordtype">size_t</span> width,
<a name="l00204"></a>00204                             <span class="keyword">const</span> <span class="keywordtype">size_t</span> height,
<a name="l00205"></a>00205                             <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *data,
<a name="l00206"></a>00206                             <span class="keyword">const</span> <span class="keywordtype">size_t</span> stride );
<a name="l00207"></a>00207 
<a name="l00213"></a>00213   <span class="keywordtype">void</span>
<a name="l00214"></a>00214   <a class="code" href="group__texture-atlas.html#gafc00ed05e30dd34ed70f6d775e441845" title="Remove all allocated regions from the atlas.">texture_atlas_clear</a>( <a class="code" href="structtexture__atlas__t.html" title="A texture atlas is used to pack several small regions into a single texture.">texture_atlas_t</a> * <span class="keyword">self</span> );
<a name="l00215"></a>00215 
<a name="l00216"></a>00216 
<a name="l00219"></a>00219 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00220"></a>00220 <span class="preprocessor"></span>}
<a name="l00221"></a>00221 <span class="preprocessor">#endif</span>
<a name="l00222"></a>00222 <span class="preprocessor"></span>
<a name="l00223"></a>00223 <span class="preprocessor">#endif </span><span class="comment">/* __TEXTURE_ATLAS_H__ */</span>
</pre></div></div><!-- contents -->
</div>
</body>
</html>
